package com.dmy.component;

import com.dmy.config.GlobleConfig;

import javax.swing.*;
import java.awt.*;

public class MJPanel extends JPanel {

    private Letter letter;
    private int tolerance = 20;

    public int getTolerance() {
        return tolerance;
    }

    public void reduction() {
        this.tolerance --;
    }

    public void setLetter(Letter letter){
        this.letter = letter;
    }

    @Override
    public void paint(Graphics g) {
        g.fillRect(0,0, GlobleConfig.WINDOW_WIDTH,GlobleConfig.WINDOW_HRIGHT);
        letter.paint((Graphics2D)g);
    }

    public String getTextInfo() {

        return "金山打字通  --当前容错数剩余："+tolerance+" --正确率："+letter.getCorrect();
    }
}
